<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改交易订单')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-orderInfo-edit" th:object="${cnanOrderInfo}">
            <h4 class="form-header h4">交易订单信息</h4>
            <input name="orderId" th:field="*{orderId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">微信应用APPID：</label>
                <div class="col-sm-8">
                    <input name="wxAppid" th:field="*{wxAppid}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">订单日期：</label>
                <div class="col-sm-8">
                    <input name="orderDate" th:field="*{orderDate}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">订单时间：</label>
                <div class="col-sm-8">
                    <input name="orderTime" th:field="*{orderTime}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">微信用户ID：</label>
                <div class="col-sm-8">
                    <input name="wxOpenid" th:field="*{wxOpenid}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">订单状态：</label>
                <div class="col-sm-8">
                    <input name="orderState" th:field="*{orderState}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">订单金额：</label>
                <div class="col-sm-8">
                    <input name="orderAmt" th:field="*{orderAmt}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">收货信息：</label>
                <div class="col-sm-8">
                    <textarea name="receivInfo" class="form-control" required>[[*{receivInfo}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">订单取消原因：</label>
                <div class="col-sm-8">
                    <textarea name="reasonsForCancel" class="form-control">[[*{reasonsForCancel}]]</textarea>
                </div>
            </div>
            <h4 class="form-header h4">订单详情信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "cnan/orderInfo";
        $("#form-orderInfo-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-orderInfo-edit').serialize());
            }
        }

        $(function() {
            var options = {
                data: [[${cnanOrderInfo.cnanOrderDetailsList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'preferId',
                    align: 'center',
                    title: '优惠ID',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='cnanOrderDetailsList[%s].preferId' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'goodsId',
                    align: 'center',
                    title: '商品ID',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='cnanOrderDetailsList[%s].goodsId' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'goodsUnitPrice',
                    align: 'center',
                    title: '商品单价',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='cnanOrderDetailsList[%s].goodsUnitPrice' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'goodsNum',
                    align: 'center',
                    title: '商品数量',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='cnanOrderDetailsList[%s].goodsNum' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'updateTime',
                    align: 'center',
                    title: '创建/更新时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='cnanOrderDetailsList[%s].updateTime' value='%s'>", index, value);
                        return html;
                    }
				
                }]
            };
            $.table.init(options);
        });

        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            sub.editColumn();
        	
            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
                    preferId: "",
                    goodsId: "",
                    goodsUnitPrice: "",
                    goodsNum: "",
                    updateTime: ""
        	    }
            });
        }
    </script>
</body>
</html>